<canvas id="myChart" height="150px;"></canvas>
<script src="../public/js/chart.js@2.8.0.js"></script>
<script>
    alabels = [];
    adata = [];
    `<?php
        foreach ($subjects as $key => $value) {
    ?>`
    alabels.push(`<?=$key?>`);
    adata.push(`<?=$value?>`);
    `<?php
        }   
    ?>`
    var subjects = [];
    var options = {
        scales: {
            xAxes: [{
                // barPercentage: 'flex',
                barThickness: 'flex',
                maxBarThickness: 150,
                minBarLength: 2,
                gridLines: {
                    offsetGridLines: true
                }

            }],
            yAxes: [{
                stacked: true,
                barPercentage: 0.5,
                barThickness: 100,
                maxBarThickness: 8,
                minBarLength: 2,
                gridLines: {
                    offsetGridLines: true
                },
                ticks: {
                    max: 100,
                    min: 0,
                    stepSize: 10
                }
            }]
        }
    };
    var ctx = document.getElementById('myChart').getContext('2d');
    var myBarChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: alabels,
            datasets: [{
                label: '成绩分析',
                fillColor: "rgba(151,187,205,0.5)",
                strokeColor: "rgba(151,187,205,0.8)",
                data: adata
            }]
        },
        options: options
    });


</script>